#pragma once
#include "map.h"

int moveTo(Map& m, int x, int y, int num, int tx, int ty){

	Point * begin = m.getPoint(x, y);
	Point * end = m.getPoint(tx, ty);
	if( begin == NULL || end == NULL){
		return -1;
	}

	if( begin->getType() != 1 || begin->getType() != 1){
		return -2;
	}

	begin->subValue(num);
	if( end->getType() == 1 ){
		end->addValue(num);
	}else if( end->getType() == 2 ){
		int real = end->subValue(num);
		if( num > real ){
			end->setType(1);
			end->addValue(num - real);
		}
	}
	return 0;
}

int getPointValue(Map& m, int x, int y){

	Point* p = m.getPoint(x, y);
	if( p == NULL ){
		return -1;
	}else{
		return p->getValue();
	}
	
}

